package max.ubitest.pipe.commands
{
	import max.ubitest.pipe.events.PipeEvent;
	import max.ubitest.pipe.locators.ComponentsLocator;
	
	import org.robotlegs.mvcs.Command;
	
	public class UnselectComponentCommand extends Command
	{
		[Inject]
		public var event:PipeEvent;
		[Inject]
		public var locator:ComponentsLocator;
		
		public function UnselectComponentCommand()
		{
			super();
		}
		
		override public function execute():void{
			if(locator.selectedComponent){
				for(var i:int = 0;i<locator.components.length;i++){
					if(locator.selectedComponent.type == locator.components.getItemAt(i).type){
						locator.components.getItemAt(i).amount ++;
						locator.selectedComponent = null;
						return;
					}
				}
			}
		}
	}
}